//     ____    _                        __     _      _____
//    / ___\  /_\     /\/\    /\ /\    /__\   /_\     \_   \
//    \ \    //_\\   /    \  / / \ \  / \//  //_\\     / /\/
//  /\_\ \  /  _  \ / /\/\ \ \ \_/ / / _  \ /  _  \ /\/ /_
//  \____/  \_/ \_/ \/    \/  \___/  \/ \_/ \_/ \_/ \____/
//
//	         Copyright The Only Love 董小菡 by 周凯东

#import "BaseModel.h"
#import "BaseHeader.h"
@implementation BaseModel


#pragma mark - dealloc

- (void)dealloc
{
    [super dealloc];
}

#pragma mark - 初始化

-(instancetype)initWithDic:(NSDictionary *)dic
{
    self = [super init];
    if (self) {
        //KVC 赋值
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}

#pragma mark - KVC容错方法
-(void)setValue:(id)value forUndefinedKey:(NSString *)key
{
    
}

-(id)valueForUndefinedKey:(NSString *)key
{
    return nil;
}
#pragma mark - 遍历构造器
+(instancetype)BaseModelWithDic:(NSDictionary *)dic
{
    id objc = [[[[self class]alloc]initWithDic:dic]autorelease];
    return objc;
}


#pragma mark - 转化方法

+(NSMutableArray *)arrayWithModelByArry : (NSArray *)array
{
    //创建一个可变数组 保存model 并返回结果
    NSMutableArray *arr = [NSMutableArray array];
    //遍历数组
    for (NSDictionary *dic in array) {
        //自动释放池
        @autoreleasepool {
      
        //创建对象
      
        id model = [[self class]BaseModelWithDic:dic];
        //添加数组
        [arr addObject:model];
    }
  }
    return arr;
}



@end
